package com.gitee.cliveyuan.tools.exception;

/**
 * 网络异常
 *
 * @author clive
 * Created on 2018/07/24
 * @since 1.0
 */
public class NetException extends BaseException {

    public NetException(int code, String message) {
        super(code, message);
    }

    public static NetException unknownHost() {
        return new NetException(1000, "Unknown Host Error");
    }

    public static NetException httpStatusError(int statusCode) {
        return new NetException(1001, "Http Status Error, statusCode:" + statusCode);
    }

    public static NetException timeout(int timeout) {
        return new NetException(1002, "Http Connect Timeout: " + timeout + " ms");
    }

    public static NetException unKnowError() {
        return new NetException(1003, "UnKnow Error");
    }

    public static NetException illegalInvokeError(String msg) {
        return new NetException(1004, "Illegal Invoke Error: " + msg);
    }

    public static NetException connectionRefused(String url) {
        return new NetException(1005, "[Connection Refused] Fail To Connect " + url);
    }

}
